Asymmetric Distributed Cache with Data Chains

ABSTRACT

An example method of loading data from a database includes receiving, at a cache node, a current query and a data chain that includes a sequence of ordered queries. The method also includes determining whether a hash of the current query matches a hash of an expected query in the data chain. The method further includes retrieving a result set of the current query from a local cache in response to determining that the hash of the current query matches the hash of the expected query. The method also includes sending the result set of the current query to a client.

FIELD OF DISCLOSURE

The present disclosure generally relates to databases, and morespecifically to retrieving result sets of queries from databases.

BACKGROUND

A client may send requests for data stored in a database. Databases mayserve as persistent storage for clients. For example, a client may senda query to the database, and the database may execute the query and senda result set back to the client. The time it takes a database to processa query and send the result set of the query back to the client may besignificant. Accordingly, it may be desirable to reduce an overall timenecessary to load data from the database.

BRIEF SUMMARY

Methods, systems, and techniques for loading data from a database areprovided.

According to some embodiments, a method of loading data from a databaseincludes receiving, at a cache node, a current query and a data chainthat includes a sequence of ordered queries. The method also includesdetermining whether a hash of the current query matches a hash of anexpected query in the data chain. The method further includes retrievinga result set of the current query from a local cache in response todetermining that the hash of the current query matches the hash of theexpected query. The method also includes sending the result set of thecurrent query to a client.

According to some embodiments, a system for loading data from a databaseincludes a cache node that receives a current query and a data chain,stores the data chain in a local cache, and hashes the current query.The data chain includes a sequence of ordered queries. The system alsoincludes a gateway that receives a plurality of queries in succession,generates one or more data chains in accordance with the plurality ofqueries received in succession, and sends one or more data chains to thecache node. The cache node determines whether a hash of the currentquery matches a hash of an expected query in the data chain, retrieves aresult set of the current query from the local cache in response todetermining that the hash of the current query matches the hash of theexpected query, and sends the result set of the current query to aclient.

According to another embodiment, a machine-readable medium includes aplurality of machine-readable instructions that when executed by one ormore processors is adapted to cause the one or more processors toperform a method including: receiving, at a cache node, a current queryand a data chain that includes a sequence of ordered queries;determining whether a hash of the current query matches a hash of anexpected query in the data chain; retrieving a result set of the currentquery from a local cache in response to determining that the hash of thecurrent query matches the hash of the expected query; and sending theresult set of the current query to a client.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which form a part of the specification,illustrate embodiments of the invention and together with thedescription, further serve to explain the principles of the embodiments.In the drawings, like reference numbers may indicate identical orfunctionally similar elements. The drawing in which an element firstappears is generally indicated by the left-most digit in thecorresponding reference number.

FIG. 1 is a block diagram illustrating a system for loading data from adatabase in accordance with some embodiments.

FIGS. 2A and 2B illustrate a process flow of the generation of one ormore data chains in accordance with some embodiments.

FIGS. 3A-3G are example process flows of loading data from a database inaccordance with some embodiments.

FIG. 4 is a flowchart illustrating a method of generating a data chainin accordance with some embodiments.

FIG. 5 is a flowchart illustrating a method of loading data from adatabase in accordance with some embodiments.

FIG. 6 is a block diagram of an electronic system suitable forimplementing one or more embodiments of the present disclosure.

DETAILED DESCRIPTION I. Overview II. Example System Architecture III.Generate Data Chains

A. Collect Queries and Store in an Order in Which They are Received

B. Search for Popular Sequences of Queries

-   -   1. A Popular Sequence of Queries is Found in Ordered Sets of        Queries    -   2. Subsequent Iterations    -   3. No Popular Sequences of Queries Are Found in Ordered Sets of        Queries

IV. Exploit the Data Chains to Improve Query Processing

A. Gateway Determines Whether Hashes of Current and Expected QueriesMatch

B. Cache Node Receives and Stores the Data Chain

-   -   1. Cache Node Processes Current Query    -   2. Cache Node Preloads a Result Set of Expected Query

C. Gateway Receives a Query From a Client

V. Example Methods VI. Example Computing System I. Overview

It is to be understood that the following disclosure provides manydifferent embodiments, or examples, for implementing different featuresof the present disclosure. Some embodiments may be practiced withoutsome or all of these specific details. Specific examples of components,modules, and arrangements are described below to simplify the presentdisclosure. These are, of course, merely examples and are not intendedto be limiting.

An application may send a similar succession of queries to a database.The present disclosure provides techniques to reduce an overall timenecessary to load data from the database. In an example, a client maycommunicate with a database to process queries based on client requests.The client may submit multiples queries to the database, and some ofthese queries may be the same. For example, a company may provide anattendance information system for employees. Employees may log theirattendance into the system and also check their current amount of paidtime off (PTO) days. A user may log into the system, check her amount ofPTO days, and then check her attendance. Based on the observation ofrequests that are sent to the database, a data chain may be created topredict which request(s) will be sent to the database. A data chainincludes a sequence of ordered queries that are submitted to thedatabase from one or more clients. Each data chain is associated with anext query pointer that references an expected query in the data chain.

According to some embodiments, a system for loading data from a databaseincludes a cache node that receives a current query and a data chain,stores the data chain in a local cache, and hashes the current query.The data chain includes a sequence of ordered queries. The system alsoincludes a gateway that receives a plurality of queries in succession,generates one or more data chains in accordance with the plurality ofqueries received in succession, and sends one or more data chains to thecache node. The cache node determines whether a hash of the currentquery matches a hash of an expected query in the data chain, retrieves aresult set of the current query from the local cache in response todetermining that the hash of the current query matches the hash of theexpected query, and sends the result set of the current query to aclient.

The present disclosure provides techniques to load data from a database.Unless specifically stated otherwise, as apparent from the followingdiscussion, it is appreciated that throughout the description,discussions utilizing terms such as “determining,” “generating,”“sending,” “receiving,” “executing,” “obtaining,” “storing,” “updating,”“removing,” “identifying,” “hashing,” “removing,” “searching,”“deleting,” or the like, refer to the action and processes of a computersystem, or similar electronic computing device, that manipulates andtransforms data represented as physical (electronic) quantities withinthe computer system's registers and memories into other data similarlyrepresented as physical quantities within the computer system memoriesor registers or other such information storage, transmission or displaydevices.

II. Example System Architecture

FIG. 1 is a block diagram illustrating a system 100 for loading datafrom a database in accordance with some embodiments. System 100 includesa gateway 102 that is coupled to clients 104 and 106 that may sendqueries to a database 120 for execution via gateway 102. Database 120may be a persistent storage that is used by clients. A client may be,for example, a web service, web application, information system, or anadministrator who/that accesses data stored in database 120. In anexample, a client sends a query to database 120, and gateway 102intercepts the query. In another example, a client sends a query togateway 102, which takes care of processing the query and returning theresult set back to the client.

Gateway 102 may collect information about the queries and observe anorder in which the queries are submitted by the clients. In someexamples, gateway 102 detects that certain queries are being submittedin certain succession (in a “data chain”), and predicts which querieswill be submitted next from clients based on gateway 102's observations.A particular sequence of ordered queries may be sent multiple times byone or more clients, and gateway 102 may detect that the sequence hasbeen sent above a threshold number of times within a time period. Ifgateway 102 detects this sequence of ordered queries has been sent abovethe threshold number of times, gateway 102 may identify the sequence ofordered queries as a popular sequence of ordered queries and generate adata chain that includes the popular sequence of ordered queries.Gateway 102 stores the data chain in a storage device for laterretrieval. The data chain may be exploited to improve the performance ofloading data from the database by proactively “preloading” data from thedatabase, as will be further discussed below.

Gateway 102 is also coupled to a distributed cache 110 that includescache nodes 112, 114, and 116. Each of cache nodes 112, 114, and 116 iscoupled to database 120 and may cache data stored in database 120. Acache node may preload data from the database by submitting a query tothe database before the cache node actually receives the query from aclient for processing. A cache node may retrieve data from its own localcache or an external source (e.g., database 120 or another cache node).

Although two clients, one gateway, one distributed cache, and onedatabase are illustrated, this is not intended to be limiting, andsystem 100 may include more than or fewer than two clients, more thanone gateway, more than one distributed cache, and/or more than onedatabase. Additionally, distributed cache 110 may include one or morecache nodes.

Each of clients 104 and 106, gateway 102, distributed cache 110, anddatabase 120 may be coupled to a network (not shown). The network may bea private network (e.g., local area network (LAN), wide area network(WAN), intranet, etc.), a public network (e.g., the Internet), or acombination thereof. The network may include various configurations anduse various protocols including virtual private networks, wide areanetworks, local networks, private networks using communication protocolsproprietary to one or more companies, cellular and other wirelessnetworks, Internet relay chat channels (IRC), instant messaging, simplemail transfer protocols (SMTP), Ethernet, Wi-Fi and Hypertext TransferProtocol (HTTP), and various combinations of the foregoing.

III. Generate the Data Chains

The present disclosure provides techniques that use data chains toreduce the overall time necessary to load data from database(s) 120.FIGS. 2A and 2B illustrate a process flow 200, 250 of the generation ofone or more data chains in accordance with some embodiments.

A. Collect Queries and Store in an Order in Which They Are Received

In FIG. 2A, at an action 202, client 104 submits a plurality of queries204 for execution to gateway 102 and/or database 120. It should beunderstood that one or more clients may send a plurality of queries togateway 102 and/or database 120. For example, client 106 may also submita plurality of queries 205 for execution to gateway 102 and/or database120. In an example, a client sends a query to database 120, and gateway102 intercepts the query. In another example, the client sends a queryto gateway 102 for processing, and gateway 102 submits the query to acache node to obtain the result set of the query.

A query may include an expressions clause (e.g., table columns fromwhich or calculations that a client desires to retrieve), one or moredatabase tables from which to retrieve the data requested by the client,and zero or more conditions clauses (e.g., condition(s) that must be metfor a database record to be selected). In an example, a query may be aStructured Query Language (SQL) query of the form “SELECT Column1,Column2, . . . , ColumnX FROM Table1, Table2, . . . , TableY WHERECondition1, Condition2, . . . , ConditionZ.”

Plurality of queries 204 includes queries 206, 208, 210, and 212, whichare an example of a succession of requests that may be sent by client104 for processing. Query 206 is “SELECT rows FROM users WHERElogin=‘tarnold’ and password=‘xxxx’”, query 208 is “SELECT profile FROMprofiles WHERE user_login=‘tarnold’”, query 210 is SELECT remainingPTOFROM vacations WHERE user_login=‘tarnold’“, and query 212 is SELECTsum(hours) FROM attendance WHERE user_login=‘tarnold’ and month=newDate(current) GROUP BY hours”. In an example, client 104 may send query206, then query 208, then query 210, and then query 212 for execution atdatabase 120, and gateway 102 may receive these queries in this order.Client 104 may submit queries 206, 208, 210, 212 consecutively in thislisted order, or may submit one or more queries between client 104'ssubmission of query 206, query 208, query 210, and/or query 212.

At an action 220, gateway 102 creates a table 222 having a plurality ofrows. In the example illustrated in FIG. 2A, table 222 includes rows224-227, and each row includes an ordered set of queries (based on theirhashes). In an example, gateway 102 hashes queries of plurality ofqueries 204 and generates an ordered set of queries for each data chaininterval. A hash of a query identifies that query, and the values intable 222 are hashes of queries. Each query in a data chain may beidentified by the hash of the query. The queries (or their hashes asillustrated in FIG. 2A) are placed in the cells of a row in accordancewith the order in which the clients submit the queries or the order inwhich gateway 102 receives the queries.

A data chain interval is the maximal time interval for the longestsequence of queries in a data chain. Gateway 102 may store data in onerow of table 222 during the data chain interval. After the data chaininterval elapses, gateway 102 may collect data for the next row of table222. The data chain interval may be, for example, 15 minutes, an hour,etc. The data chain interval may vary depending on various factors suchas the number of queries expected from clients per time unit, etc. Inthis example, the more queries that are expected from clients per unittime, the shorter the data chain interval may be.

In an example, during a first data chain interval, gateway 102 receivesand hashes query 206 to produce the hash “1” and stores it in the firstcell of row 224 in table 222, receives and hashes another query toproduce the hash “9” and stores it in the second cell of row 224 intable 222, and so on. During a second data chain interval, gateway 102receives and hashes a query to produce the hash “3” and stores it in thefirst cell of row 225 in table 222, hashes another query to produce thehash “6” and stores it in the second cell of row 225 in table 222, andso on. The hashes in table 222 may identify queries that are sent fromboth clients 104 and 106.

B. Search for Popular Sequences of Queries

Gateway 102 identifies one or more popular sequences of queries in thereceived queries sent in succession. Queries listed in a popularsequence of queries may be listed in an order in which they were sentfrom a client or received at gateway 102. It should be understood thatit is unnecessary for the queries to be sent consecutively one after theother. Rather, zero or more queries may have been received by gateway102 between receiving two adjacent queries listed in a popular sequenceof queries.

Gateway 102 may determine whether particular conditions are satisfiedbefore searching for popular sequences of queries in table 222. Forexample, gateway 102 may determine whether a number of rows in table 222is greater than a count threshold. A count threshold indicates how manydata chain intervals (or rows in table 222) are needed to generate adata chain. In this example, gateway 102 may wait until it has generatedN ordered sets of queries before detecting data chains, where N is thecount threshold and greater than 1.

Additionally, gateway 102 may use various criteria to detect a popularsequence of queries. For example, gateway 102 may determine whether afrequency in which a particular sequence of queries appears in rows224-227 is greater than a frequency threshold. The frequency thresholdindicates an expected frequency of a particular sequence of queriesbefore it can be identified as a popular sequence of queries. In anotherexample, gateway 102 may determine whether a length of a particularsequence of queries in rows 224-227 is greater than a length threshold.A length threshold indicates the minimal length of a popular sequence ofqueries.

In an example, the data chain interval is 15 minutes, N is 30, thefrequency threshold is 5%, and the length threshold is 20. In anotherexample, the data chain interval is an hour, N is 4, the frequencythreshold is 50%, and the length threshold is 3. In this example,gateway 102 generates a new row that includes an ordered set of queriesevery hour (e.g., generates row 224 after the first hour, generates row225 after the second hour, and so on), and inserts this new row intotable 222. In an example, if gateway 102 inserts a new row N+1 (e.g.,row 5 in table 222) into table 222, gateway 102 discards the oldest rowin table 222. In this example, table 222 may remain at a manageablesize. In another example, if gateway 102 inserts a new row N+1 intotable 222, gateway 102 replaces the oldest row in table 222 with the newrow.

1. A Popular Sequence of Queries is Found in the Ordered Sets of Queries

At an action 230, gateway 102 starts searching for popular sequences ofqueries in table 222 after the 4 ordered sets of queries have beengenerated and stored in table 222. Gateway 102 may continually searchthe rows in table 222 for popular sequences of queries as new data isinserted into table 222. In a first iteration, gateway 102 searches theN (e.g., four rows 224-227) ordered sets of queries for one or morepopular sequences of queries, where N is the count threshold. In anexample, gateway 102 searches for a longest popular sequence of queriesin table 222, where a frequency in which the popular sequence of queriesappears in the 4 ordered sets of queries (rows 224-227) is greater thanthe frequency threshold (e.g., 50%). In another example, gateway 102searches for a longest popular sequence of queries in table 222, where alength of the longest popular sequence of queries is greater than thelength threshold (e.g., 3). In some examples, gateway 102 uses both thefrequency threshold and the length threshold as criteria in detectingpopular sequences of queries.

Gateway 102 may find a longest popular sequence of queries that abidesby the criteria. In keeping with the above examples in which thefrequency threshold is 50% and the length threshold is 3, sequence ofqueries “1354” appears in three of the four rows (75% of the rows),which is greater than the 50% frequency threshold, and has a chainlength of 4, which is greater than the length threshold of 3.Accordingly, gateway 102 may detect the sequence of queries “1354,”which is shown as a shaded area in table 222, as being a popularsequence of queries. A sequence of ordered queries may be in the form ofthe queries themselves or their hashes. In an example, the hash of query206 is “1”, the hash of query 208 is “3”, the hash of query 210 is “5”,and the hash of query 212 is “4”. In this example, sequence of queries“1354” refers to queries 206, 208, 210, and 212, respectively.

Gateway 102 generates one or more data chains based on the one or moreidentified popular sequences of queries. Gateway 102 may generate datachains dynamically during runtime. At an action 232, gateway 102generates a data chain 234 and saves the data chain in a data storagedevice 236. Data chain 234 includes the hashes “1”, “3”, “5”, and “4” ofthe popular sequence of ordered queries “1354” and a blank result set.In some examples, gateway 102 creates a linked list of elements, whereeach element includes a hash of a query in the popular sequence ofqueries and a result set of the respective query. The elements includedin data chain 234 may be ordered in accordance with the popular sequenceof ordered queries.

A blank data chain is a data chain that has not been activated by acache node yet. A cache node activates a data chain when it receives aquery that is included in the data chain. Gateway 102 maintains a nextquery pointer that references the next expected query to be submitted bya client. Each query that precedes the expected query in the sequencehas been processed by a cache node. A next query pointer may beinitialized by referencing a value indicating that the data chain hasnot yet been activated yet. In an example, the value is the firstelement in data chain 234. In another example, the value is NULL.

Additionally, data chain 234 has an “Assigned” field 240 that indicateswhether the data chain has been activated by a cache node yet and if so,which cache node. If the value of the “Assigned” field 240 in a datachain is NULL or empty, then the data chain has not been activated yet.

In the example illustrated in FIG. 2A, a data chain includes a pluralityof elements, where each element includes a hash of a query and itsresult set. This is not intended be limiting, and data chain may includemore or less information than that shown in data chain 234. In someexamples, a data chain includes the query itself, a timestamp of whenthe query was sent by the client and/or received by gateway 102, and/orother information.

Additionally, a data chain may store data in its elements in a differentmanner. For example, a first element in a data chain may store thesequence of ordered queries, a second element in the data chain maystore the hashes in an order in accordance with their correspondingqueries listed in the first element, and a third element in the datachain may store the results sets of queries in an order in accordancewith their corresponding queries listed in the first element. In anotherexample, a data chain may be represented as an array that stores eachhash of a query listed in the popular sequence of queries. In thisexample, gateway 102 may keep an index count that indicates the nextexpected query to be submitted. These are merely examples that are notintended to be limiting.

At an action 242, gateway 102 removes each occurrence of the popularsequence of ordered queries (“1354”) from table 222 to produce table222′.

2. Subsequent Iterations

In a second iteration, gateway 102 starts searching for one or morepopular sequences of queries in table 222′ using the techniquesdescribed in relation to table 222. In FIG. 2B, at an action 230,gateway 102 continues to search for popular sequences of queries intable 222′. Gateway 102 may detect the sequence of queries “389,” whichis shown as a shaded area in table 222′, as being a popular sequence ofqueries in the table.

At an action 252, gateway 102 generates a data chain 254 and saves thedata chain in data storage device 236. Data chain 254 includes thehashes “3”, “8”, and “9” of the popular sequence of queries “389” and ablank result set. Gateway 102 maintains a next query pointer 258 thatreferences the next expected query to be submitted by a client in datachain 2554. Next query pointer 258 may be initialized by referencing avalue indicating that the data chain has not been activated yet. In anexample, the value is the first element in data chain 236. In anotherexample, the value is NULL. Additionally, data chain 236 has an“Assigned” field 260 that indicates whether the data chain has beenactivated by a cache node yet and if so, which cache node.

At an action 262, gateway 102 removes each occurrence of the popularsequence of queries (“289”) from table 222′ to produce table 222″. In athird iteration, gateway 102 starts searching for one or more popularsequences of ordered queries in table 222″ using the techniquesdescribed in relation to table 222.

2. No Popular Sequences of Queries are Found in Ordered Sets of Queries

Gateway 102 may be unable to find any more popular sequences of orderedqueries that satisfy the criteria (e.g., frequency threshold=50% andlength threshold=3). If gateway 102 does not find a popular sequence ofqueries that satisfies the criteria, then gateway 102 may temporarilycease to detect data chains until another row is added to the table. Insome examples, gateway 102 inserts the new rows into table 222 andsearches this table. In some examples, gateway 102 inserts the new rowinto table 222′ (the resulting table after the popular sequence(s) ofordered queries is removed from table 222) and searches this table.

IV. Exploit the Data Chains to Improve Query Processing

After gateway 102 has generated one or more data chains, gateway 102 anddistributed cache 110 may start to leverage this knowledge to improvequery processing and response time. Gateway 102 and distributed cache110 may maximize the cache hit ratio using prediction and the datachains. Using a data chain, a cache node may be able to reduce theresponse time of a query because the cache node is able to successfullypredict queries and load result sets of queries from external sourcesbefore the cache node actually receives the queries for processing. Acache node loads data that it expects to be requested, in advance. Eachof the cache nodes may be associated with its own cache, and a cachenode may cache one or more data chains. Each cached data chain mayinclude a hash of a query and either a blank result set or the resultset of the query. Every cache associated with a cache node may containunique data. An advantage of an embodiment may be ease of scalability.For example, a cache node may be easy to add to distributed cache 110.

FIGS. 3A-3G are example process flows 300, 320, 330, 340, 350, 360, and370 of loading data from a database in accordance with some embodiments.In FIG. 3A, at an action 302, client 104 sends query 208 for executionat database 120, and gateway 102 receives query 208. At an action 304,gateway 102 hashes query 208. The hash of query 208 is “3.” Query 208may also be referred to as the “current query” because the query hasbeen sent by a client but not yet processed.

A. Gateway Determines Whether Hashes of Current and Expected QueriesMatch

Gateway 102 determines whether the hash of query 208 matches any hash ofan expected query in data storage device 236. Gateway 102 maintains datastorage device 236. In FIG. 3A, data storage device 236 stores datachains 234 and 236, and each of these data chains has an expected query.Next query pointer 238 references the expected query (identified by hash“1”) in data chain 234, and next query pointer 258 references theexpected query (identified by hash “3”) in data chain 236. In someexamples, if the next query pointer associated with a data chainreferences NULL, the expected query of the data chain is the query inthe first element listed in the data chain.

If gateway 102 determines that the hash of query 208 does not match ahash of any of the expected queries in data chain 234 or data chain 254,gateway 102 may select any of the cache nodes in distributed cache 110to process query 208. In an example, a hash of query 208 does not matcha hash of any of the expected queries in data chain 234 or 254 if thehash is not equal to “1” or “3.” Alternatively, the hash of query 208matches a hash of an expected query in data chain 234 or 254 if the hashis equal to “1” or “3.”

When gateway 102 receives a current query from a client, gateway 102tries to find a data chain in data storage device 236 that has a nextquery pointer that references an element that stores the hash of thecurrent query. At an action 306, gateway 102 determines whether the hashof query 208 (“3”) matches a hash of any of the expected queries in datachain 234 or data chain 254. The hash of query 208 matches the hash ofthe first query listed in data chain 254 and identified by the hash “3”.

A data chain matches a hash of a current query if the hash of theexpected query in the data chain matches the hash of the current query.Gateway 102 may determine whether the matching data chain 256 has beenactivated. If the matching data chain has not been assigned to a cachenode yet, then the data chain has not been activated. At an action 308,if the data chain has not been assigned to a cache node in data chainyet, gateway 102 assigns the data chain to a cache node and sends thedata chain along with query 208 to the assigned cache node. Aftergateway 102 has received an expected query in a data chain, gateway 102updates the next query pointer to reference the next element in the datachain. Gateway 102 may evenly distribute unactivated data chains tocache nodes in distributed cache 110.

B. Cache Node Receives and Stores the Data Chain 1. Cache Node ProcessesCurrent Query

In FIG. 3B, cache node 112 may receive data chain 254 and query 208 fromgateway 102, and store data chain 254 in its associated cache 310. Theresult sets of the queries identified by hashes “3”, “8”, and “9” areempty because the result sets of these queries have not yet beenretrieved by cache node 112. Because a result set of query 208, whichcorresponds to hash “3” is not stored in cache 310, cache node 112submits query 208 to an external source to obtain a result set of query208. Cache node 112 retrieves the result set of query 208 from theexternal source. Although cache node 112 is described as processing andstoring a data chain, it should be understood that any of the cachenodes may process and store a data chain.

At an action 322, cache node 112 submits query 208 to database 120 forexecution. Database 120 may execute query 208 against its databasetables, retrieve a result set of query 208, and send the result set ofquery 208 to cache node 112. Cache node 112 receives the result set ofquery 208. At an action 324, cache node 112 stores the result set ofquery 208 in the element to which next query pointer 358 references indata chain 254.

In some examples, cache node 112 retrieves the result set of query 120from an external source that is not database 120. In an example, cachenode 112 determines whether any of the other cache nodes in distributedcache 110 (e.g., cache node 114 or cache node 116) has a result set ofquery 208 cached. Cache node 112 may send a request to cache node 114for this result set. If cache node 114 has the result set of query 208cached, cache node 114 may send it to cache node 112, which then cachesthe result set of query 208 in cache 310 and returns the result set ofquery 208 to client 104. Alternatively, cache node 114 may send theresult set of query 208 to client 104, and send a message to cache node112 that cache node 114 has sent the result set of query 208 to theclient. In this case, cache node 112 may store in the result set of thefirst element a reference to cache node 114 (or its associated cache)and update the applicable next query pointer if cache node 114 has acached result set of this query. In some examples, if cache node 112does not have a result set of a query in cache 310, cache node 112always attempts to find the result set of the query in any other cachenodes before cache node 112 loads or preloads data directly fromdatabase 120.

FIG. 3C illustrates an example of cache 310 after cache node 112 storesthe result set of query 208 in the element to which next query pointer358 references and updates next query pointer 358 in accordance withsome embodiments. In FIG. 3C, the result set of query 208 is cached indata chain 254. After cache node 112 has finished processing a queryreferenced by the next query pointer, cache node 112 may update the nextquery pointer to reference the next element in the data chain. In anexample, cache node 112 has finished processing a query if cache node112 has retrieved a result set of the query or has sent the result setof the query to a client via gateway 102.

At an action 332, cache node 112 updates next query pointer 358 toreference the next consecutive element listed in data chain 254. Nextquery pointer 358′, which references the second element listed in datachain 254, represents the updated next query pointer 358. Next querypointer 358′ references a query in data chain 254 that cache node 112expects to receive next; this query may be referred to as the expectedquery.

2. Cache Node Preloads a Result Set of Expected Query

The next query in data chain 254 is identified by the hash “8”. Cachenode 112 may leverage the knowledge it has in knowing that the queryidentified by hash “8” is predicted to be sent by a client.Additionally, the query identified by hash “9” is predicted to be sentby a client after the query identified by hash “8” is received. Cachenode 112 may “preload” the result sets of one or more these queries bysubmitting them to database 120 before actually receiving these queriesfor processing. A cache node may preload M consecutive requests, where Mis a number greater than 0. For example, if M is 1, then cache node 112may preload a result set of the query identified by the hash “8”. If Mis 2, then cache node 112 may preload two result sets, a result set ofthe query identified by the hash “8” and a result set of the queryidentified by the hash “9”. When a cache node preloads a result set of aquery, the cache node may send a message to gateway 102 that the cachenode is preloading the result set of the query.

In FIG. 3C, query 334 may be the query identified by hash “8”. In anexample, cache node 112 determines this query by sending a request togateway 102 for the actual query itself. In another example, this queryis included in a data chain that is sent by gateway 102 and isassociated with the hash “8”. At an action 336, cache node 112 submitsquery 334 to an external source in order to retrieve a result set ofquery 334. In the example illustrated in FIG. 3C, cache node 112 submitsquery 334 to database 120 for execution. Database 120 may execute query334 against its database tables, retrieve a result set of query 334, andsend the result set of query 334 to cache node 112. Cache node 112receives the result set of query 334. At an action 338, cache node 112stores the result set of query 334 in the element to which next querypointer 358′ references in data chain 254. Cache node 112 may preloadthe following (M−1) result sets of queries sequentially.

FIG. 3D illustrates an example of cache 310 after cache node 112 storesthe result set of query 334 in the cache in accordance with someembodiments. In FIG. 3D, the result set of query 334 is stored in cache310. After cache node 112 receives an expected query from gateway 102,cache node 112 will update the next query pointer that references thatexpected query to reference the next element listed in the data chain.For example, after cache node 112 receives and processes the queryidentified by the hash “8”, cache node 112 updates next query pointer358′ to reference the next subsequent element in data chain 254.

C. Gateway Receives a Query From a Client

FIG. 3E illustrates example process flow 350 of gateway 102 receiving aquery for processing from a client. In FIG. 3E, at an action 352, client104 sends a current query 334 for execution at database 120, and gateway102 receives the current query. At an action 356, gateway 102 hashescurrent query 334. The hash of current query 334 is “8.” Query 334 mayalso be referred to as the “current query” because the query has beensent by a client but not yet processed.

At an action 358, gateway 102 determines whether the hash of query 334(“8”) matches a hash of any of the expected queries in data storagedevice 236, which stores data chain 234 or data chain 254. The hash ofquery 334 matches the hash of the second query listed in data chain 254and referenced by next query pointer 258. Gateway 102 may determinewhether the matching data chain 254 has been activated. In FIG. 3E, datachain 254 has been activated because the data chain has been assigned toa cache node.

At an action 359, if the matching data chain 254 has been activated,gateway 102 sends query 334 to the assigned cache node, which in thisexample is cache node 112. Gateway 102 may also send the hash of query334, or leave it up to cache node 112 to hash query 334. After gateway102 has received the expected query referenced by next query pointer258, gateway 102 updates next query pointer 258 to reference the nextelement in the data chain. Accordingly, gateway 102 updates next querypointer 258 to reference the element including the hash “9”.

In FIG. 3F, cache node 112 may receive query 334 from gateway 102. At anaction 362, cache node 112 hashes query 334. The hash of query 334 is“8”. At an action 364, cache node 112 determines whether the hash ofquery 334 (“8”) matches a hash of any of the expected queries in datachain 254. Reference 358′ references an element including the hash “8”,which matches the hash of current query 334. At an action 366, cachenode 112 retrieves the result set of query 334 from cache 310 and sendsthis result set to gateway 102. In this example, it is unnecessary forcache node 112 to request the result set of query 334 from an externalsource (e.g., database 120 or another cache node). Cache node 112 maythen update next query pointer 358′ to reference the next element listedin data chain 254.

FIG. 3G illustrates an example of cache 310 after cache node 112 updatesnext query pointer 358′ in accordance with some embodiments. In FIG. 3E,after cache node 112 receives the expected query identified by hash “8”from gateway 102, cache node 112 updates next query pointer 358′ toreference the next element listed in the data chain. Next query pointer358″, which references the last element listed in data chain 254,represents the updated next query pointer 358′. Next query pointer 358″references a query in data chain 254 that cache node 112 expects toreceive next; this query may be referred to as the expected query. Cachenode 112 may preload a result set of the query identified by the hash“9” and store the result set in cache 310.

In FIG. 3G, updated next query pointer 358″ references the last elementin data chain 254. At a later point in time, if cache node 112 receivesthe query identified by the hash “9”, cache node 112 may process thequery by retrieving it from cache 310. Additionally, cache node 112 maysend a message to gateway 102 that data chain 254 was predictedsuccessfully and delete data chain 254 from cache 310. In some examples,if a time interval has elapsed and cache node 112 has still not receivedthe last query in a data chain for processing for a client, cache node112 may delete the data chain or set the result sets in the data chainto a blank state.

Gateway 102 may continually and simultaneously generate an ordered setof queries for each data chain interval to add to table 222, detect apopular sequence of queries in the ordered sets of queries, and senddata chains, hashes, and/or queries to cache nodes for processing.

As discussed above and further emphasized here, FIGS. 1, 2A-2B, and3A-3G are merely examples, which should not unduly limit the scope ofthe claims.

V. Example Methods

FIG. 4 is a flowchart illustrating a method 400 of generating a datachain in accordance with some embodiments. Method 400 is not meant to belimiting and may be used in other applications.

In FIG. 4, method 400 includes blocks 402-412. In a block 402, aplurality of queries from one or more clients is received. In anexample, gateway 102 receives a plurality of queries from one or moreclients 104 and 106. In a block 404, an ordered set of queries for eachdata chain interval is generated, the ordered set of queries including ahash of the respective received query. In an example, gateway 102generates row 224-227, where each row includes an ordered set of queriesand is generated for each data chain interval. The ordered set ofqueries includes a hash of the respective received query.

In a block 406, N ordered sets of queries are searched for a popularsequence of queries, where N is a number of data chain intervals neededto generate a data chain. In an example, gateway 102 searches N orderedsets of queries for a popular sequence of queries in table 222, where Nis a number of data chain intervals needed to generate a data chain. Ina block 408, a popular sequence of the received queries sent insuccession is identified in the N ordered sets of queries. In anexample, gateway 102 identifies a popular sequence of the receivedqueries sent in succession in the N ordered sets of queries. In a block410, a data chain including a popular sequence of queries and a hash ofeach of the queries of the popular sequence of queries is generated. Inan example, gateway 102 generates a data chain including a popularsequence of queries and a hash of each of the queries of the popularsequence of queries. In a block 412, the generated data chain is storedin a data storage device. In an example, gateway 102 stores thegenerated data chain in data storage device 236.

It is understood that additional processes may be inserted before,during, or after blocks 402-412 discussed above. It is also understoodthat one or more of the blocks of method 400 described herein may beomitted, combined, or performed in a different sequence as desired.

FIG. 5 is a flowchart illustrating a method 500 of loading data from adatabase in accordance with some embodiments. Method 500 is not meant tobe limiting and may be used in other applications.

In FIG. 5, method 500 includes blocks 502-508. In a block 502, a currentquery and a data chain that includes a sequence of ordered queries arereceived. In an example, cache node 112 receives current query 334 (seeFIG. 3F) and data chain 254 that includes a sequence of ordered queriesidentified by hashes “3”, “8”, and “9”. In a block 504, it isdetermining whether a hash of the current query matches a hash of anexpected query in the data chain. In an example, cache node 112determines whether a hash of current query 334 matches a hash of anexpected query in data chain 254. In a block 506, a result set of thecurrent query is retrieved from a local cache in response to determiningthat the hash of the current query matches the hash of the expectedquery. In an example, cache node 112 retrieves a result set of currentquery 334 from cache 310 in response to determining that the hash ofcurrent query 334 matches the hash of the expected query. In an block508, the result set of the current query is sent to a client. In anexample, cache node 112 sends the result set of current query 334 toclient 114.

In some embodiments, one or more actions illustrated in blocks 502-508may be performed for any number of queries received by a cache node.Additionally, it is also understood that additional processes may beinserted before, during, or after blocks 502-508 discussed above. It isalso understood that one or more of the blocks of method 500 describedherein may be omitted, combined, or performed in a different sequence asdesired.

VI. Example Computing System

FIG. 6 is a block diagram of a computer system 600 suitable forimplementing one or more embodiments of the present disclosure. Each ofcache nodes 112, 114, and 116, clients 104 and 106, and gateway 102 mayexecute on a computing device. The computing device may include one ormore storage devices each selected from a group including a floppy disk,flexible disk, hard disk, magnetic tape, any other magnetic medium,CD-ROM, any other optical medium, RAM, PROM, EPROM, FLASH-EPROM, anyother memory chip or cartridge, and/or any other medium from which aprocessor or computer is adapted to read. The one or more storagedevices may include stored information that may be made available to oneor more computing devices and/or computer programs (e.g., clients)coupled to the application server using a computer network (not shown).The computer network may be any type of network including a LAN, a WAN,an intranet, the Internet, a cloud, and/or any combination of networksthereof that is capable of interconnecting computing devices and/orcomputer programs in the system.

Computer system 600 includes a bus 602 or other communication mechanismfor communicating information data, signals, and information betweenvarious components of computer system 600. A processor 612, which may bea micro-controller, digital signal processor (DSP), or other processingcomponent, processes these various signals, such as for display oncomputer system 600 or transmission to other devices via communicationslink 608. Components of computer system 600 also include a system memorycomponent 634 (e.g., RAM), a static storage component 616 (e.g., ROM),and/or a disk drive 617. Computer system 600 performs specificoperations by processor 612 and other components by executing one ormore sequences of instructions contained in system memory component 634.

Components include an input/output (I/O) component 604 that processes auser action, such as selecting keys from a keypad/keyboard, selectingone or more buttons or links, etc., and sends a corresponding signal tobus 602. I/O component 404 may include an output component such as adisplay 611, and an input control such as a cursor control 613 (such asa keyboard, keypad, mouse, etc.). An optional audio I/O component 605may also be included to allow a user to use voice for inputtinginformation by converting audio signals into information signals. AudioI/O component 605 may allow the user to hear audio. A transceiver ornetwork interface 606 transmits and receives signals between computersystem 600 and other devices via a communications link 608 to a network.In an embodiment, the transmission is wireless, although othertransmission mediums and methods may also be suitable.

Logic may be encoded in a computer readable medium 617, which may referto any medium that participates in providing instructions to processor612 for execution. Such a medium may take many forms, including but notlimited to, non-volatile media, volatile media, and transmission media.In various implementations, non-volatile media includes optical, ormagnetic disks, or solid-state drives, volatile media includes dynamicmemory, such as system memory component 634, and transmission mediaincludes coaxial cables, copper wire, and fiber optics, including wiresthat include bus 602. In an embodiment, the logic is encoded innon-transitory computer readable medium. Transmission media may take theform of acoustic or light waves, such as those generated during radiowave, optical, and infrared data communications.

Some common forms of computer readable media include, for example,floppy disk, flexible disk, hard disk, magnetic tape, any other magneticmedium, CD-ROM, any other optical medium, punch cards, paper tape, anyother physical medium with patterns of holes, RAM, PROM, EEPROM,FLASH-EEPROM, any other memory chip or cartridge, or any other mediumfrom which a computer is adapted to read. In various embodiments of thepresent disclosure, execution of instruction sequences (e.g., method 400or method 500) to practice the present disclosure may be performed bycomputer system 600. In various other embodiments of the presentdisclosure, a plurality of computer systems 600 coupled bycommunications link 608 to the network (e.g., such as a LAN, WLAN, PTSN,and/or various other wired or wireless networks, includingtelecommunications, mobile, and cellular phone networks) may performinstruction sequences to practice the present disclosure in coordinationwith one another.

Where applicable, various embodiments provided by the present disclosuremay be implemented using hardware, software, or combinations of hardwareand software. Also where applicable, the various hardware componentsand/or software components set forth herein may be combined intocomposite components including software, hardware, and/or both withoutdeparting from the spirit of the present disclosure. Where applicable,the various hardware components and/or software components set forthherein may be separated into sub-components including software,hardware, or both without departing from the spirit of the presentdisclosure. In addition, where applicable, it is contemplated thatsoftware components may be implemented as hardware components, andvice-versa.

Application software in accordance with the present disclosure may bestored on one or more computer readable media. It is also contemplatedthat the application software identified herein may be implemented usingone or more general purpose or specific purpose computers and/orcomputer systems, networked and/or otherwise. Where applicable, theordering of various blocks described herein may be changed, combinedinto composite blocks, and/or separated into sub-blocks to providefeatures described herein.

The foregoing disclosure is not intended to limit the present disclosureto the precise forms or particular fields of use disclosed. As such, itis contemplated that various alternate embodiments and/or modificationsto the present disclosure, whether explicitly described or impliedherein, are possible in light of the disclosure. Changes may be made inform and detail without departing from the scope of the presentdisclosure. Thus, the present disclosure is limited only by the claims.

What is claimed is:
 1. A method of loading data from a database,comprising: receiving, at a cache node, a current query and a data chainthat includes a sequence of ordered queries; determining whether a hashof the current query matches a hash of an expected query in the datachain; retrieving a result set of the current query from a local cachein response to determining that the hash of the current query matchesthe hash of the expected query; and sending the result set of thecurrent query to a client.
 2. The method of claim 1, wherein each querythat precedes the expected query in the sequence has been processed. 3.The method of claim 1, further including: receiving, at the cache node,a first listed query in the data chain, wherein the expected query isthe next query in the sequence after the first listed query; retrievinga result set of the first listed query; sending the result set of thefirst listed query to the client; updating a next query pointer toreference the expected query in the data chain; retrieving a result setof the expected query from an external source; and storing the resultset of the expected query in the local cache.
 4. The method of claim 1,wherein the current query is the expected query.
 5. The method of claim1, wherein the current query is different from the expected query. 6.The method of claim 1, further including: receiving, at a gateway, aplurality of queries from one or more clients; identifying one or morepopular sequences of the received queries sent in succession; hashingeach query of the plurality of queries; generating one or more datachains, each data chain including a popular sequence of queries and ahash of each of the queries of the popular sequence of queries; andstoring the one or more generated data chains into a data storagedevice.
 7. The method of claim 6, further including: generating anordered set of queries for each data chain interval, the ordered set ofqueries including a hash of the respective received query; searching Nordered sets of queries for a popular sequence of queries, wherein N isa number of data chain intervals needed to generate a data chain;removing the popular sequence of queries from the N ordered sets ofqueries to produce a first updated N ordered sets of queries in responseto finding the popular sequence of queries.
 8. The method of claim 7,further including: after the removing, searching the first updated Nordered sets of queries for a second popular sequence of queries;removing the second popular sequence of queries from the first updated Nordered sets of queries to produce a second updated N ordered sets ofqueries in response to finding the popular sequence of queries.
 9. Themethod of claim 6, wherein a length of each popular sequence is greaterthan a length threshold.
 10. The method of claim 6, wherein a frequencyin which each popular sequence appears in the N ordered sets of queriesis greater than a frequency threshold.
 11. The method of claim 1,wherein a next query pointer references the expected query in the datachain, further including: determining whether the expected query is thelast query in the sequence; deleting the data chain from the local cachein response to determining that the expected query is the last query inthe sequence; and updating the next query pointer to reference the nextquery in the sequence in response to determining that the expected queryis not the last query in the sequence.
 12. A system for loading datafrom a database, comprising: a cache node that receives a current queryand a data chain, stores the data chain in a local cache, and hashes thecurrent query, wherein the data chain includes a sequence of orderedqueries; and a gateway that receives a plurality of queries insuccession, generates one or more data chains in accordance with theplurality of queries received in succession, and sends one or more datachains to the cache node; wherein the cache node determines whether ahash of the current query matches a hash of an expected query in thedata chain, retrieves a result set of the current query from the localcache in response to determining that the hash of the current querymatches the hash of the expected query, and sends the result set of thecurrent query to a client.
 13. The system of claim 12, wherein eachquery that precedes the expected query in the sequence has beenprocessed.
 14. The system of claim 12, wherein the cache node receives afirst listed query in the data chain, and the expected query is the nextquery in the sequence after the first listed query, wherein the cachenode retrieves a result set of the first listed query and sends theresult set of the first listed query to the client
 15. The system ofclaim 12, wherein the cache node updates a next query pointer toreference the expected query in the data chain, retrieves a result setof the expected query from an external source, and stores the result setof the expected query in the local cache.
 16. The system of claim 15,wherein the external source is a database that stores the result set ofthe expected query.
 17. The system of claim 15, wherein the externalsource is a second cache node.
 18. The system of claim 12, wherein anext query pointer references the expected query in the data chain. 19.The system of claim 18, wherein the cache node determines whether theexpected query is the last query in the sequence, wherein the cache nodedeletes the data chain from the local cache in response to determiningthat the expected query is the last query in the sequence, and updates anext query pointer to reference the next query in the sequence inresponse to determining that the expected query is not the last query inthe sequence.
 20. A machine-readable medium comprising a plurality ofmachine-readable instructions that when executed by one or moreprocessors is adapted to cause the one or more processors to perform amethod comprising: receiving, at a cache node, a current query and adata chain that includes a sequence of ordered queries; determiningwhether a hash of the current query matches a hash of an expected queryin the data chain; retrieving a result set of the current query from alocal cache in response to determining that the hash of the currentquery matches the hash of the expected query; and sending the result setof the current query to a client.